package voja.android.sqldroid;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    
	Button btnSettings;
	SharedPreferences prefs;
	
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        prefs = getSharedPreferences(SettingsActivity.PREFS_NAME, 0);
        
        btnSettings = (Button)findViewById(R.id.btnSettings);
		btnSettings.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
				startActivity(intent);
			}
		});
		loadPrefs();
    }
    
    public void onStart(){
    	super.onStart();
    	loadPrefs();
    }
    
    public void loadPrefs(){
    	TextView tv = (TextView)findViewById(R.id.tvDestination);
		tv.setText(prefs.getString("destination", ""));
    }
}